home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0221_Reading-Writing Ports in DELPHI.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  624 b   |  29 lines

  1.  
  2. In the old days writing to ports on your computer was easy; all you had
  3. to do was use the port[ n ] command.
  4.  
  5. Delphi no longer supports the port[ n ] command, so you have to use
  6. functions like:
  7.  
  8. function ReadPortB( wPort : Word ) : Byte;
  9. begin
  10. asm
  11. mov dx, wPort
  12. in al, dx
  13. mov result, al
  14. end;
  15. end;
  16.  
  17. procedure WritePortB( wPort : Word; bValue : Byte );
  18. begin
  19. asm
  20. mov dx, wPort
  21. mov al, bValue
  22. out dx, al
  23. end;
  24. end;
  25.  
  26.  
  27.  
  28.                                 Of course, your operating system may not let you write to certain ports,
  29.                                 specially if you're running on Windows NT.